package com.example.restaurant.controller;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.restaurant.common.Result;
import com.example.restaurant.controller.form.AddOrderInfoForm;
import com.example.restaurant.controller.form.QueryOrderInfoForm;
import com.example.restaurant.model.OrderInfo;
import com.example.restaurant.service.OrderInfoService;
import com.example.restaurant.service.dto.PageOrderInfoDto;
import com.example.restaurant.service.param.AddOrderInfoParam;
import com.example.restaurant.service.param.QueryOrderInfoParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 订单详情表 前端控制器
 * </p>
 *
 * @author x
 * @since 2022-09-29
 */
@RestController

public class OrderInfoController {
    @Resource
    private OrderInfoService orderInfoService;

//    @PostMapping("addOrderInfo")
//    public Result addOrderInfo(@Valid @RequestBody AddOrderInfoForm form){
//        AddOrderInfoParam addOrderInfoParam = BeanUtil.copyProperties(form, AddOrderInfoParam.class);
//        orderInfoService.addOrderInfo(addOrderInfoParam);
//        return Result.success();
//    }

    @GetMapping("getOrderInfo")
    public Result queryOrderInfo(String orderNumber,@RequestParam(defaultValue = "1") Integer current,@RequestParam(defaultValue = "10")Integer size){
        Page<OrderInfo> orderInfoPage = orderInfoService.queryOrderInfo(orderNumber, current, size);
        return Result.success(orderInfoPage);
    }
}
